<?php
	//include_once('Models/LopHocPhan.php');
	
	$malophp = $_GET['malophp'];
	include_once('Configs/database.php');
	include_once('Models/NhatKi.php');
	include_once('Models/LopHocPhan.php');
	include_once('Models/NhomThucHanh.php');
	$nhatki = new NhatKi();;
	$lophp = new LopHocPhan();
	
	$db = new database();
	$db2 = new database();
	//$namhoc = $_GET['namhoc'];
	//$hocki = $_GET['hocki'];
	//$maso = $_GET['maso'];
	//$namhoc = $_POST['namhoc'];
	//$hocki = $_POST['hocki'];
	//$maso = $_POST['maso'];
	$query = "select distinct tenhp,kihieu,sotc,a.malophp,siso,a.mahp,manhom,sotietlithuyet,sotietthuchanh ";
	$query .= "from LopHocPhan a, HocPhan b ";
	$query .= "where maso='".$maso."' and hocki=".$hocki." and namhoc='".$namhoc."' ";
	$query .= "and a.mahp = b.mahp order by a.mahp ";
	$db->setQuery($query);
	
	//echo $db->getQuery();
	$result = $db->fetchAll();
	
	$result2 = $db->fetchAll();
	$result3 = $db->fetchAll();
	$result4 = $db->fetchAll();
	$result5 = $db->fetchAll();
	
	$query2 = "select distinct tenhp,c.kihieu,sotc,a.malophp,manhomth,c.siso,a.mahp,manhom,sotietlithuyet,sotietthuchanh ";
	$query2 .= "from LopHocPhan a, HocPhan b,NhomThucHanh c ";
	$query2 .= "where c.maso='".$maso."' and hocki=".$hocki." and namhoc='".$namhoc."' ";
	$query2 .= "and a.mahp = b.mahp and a.malophp=c.malophp order by a.mahp ";
	$db2->setQuery($query2);
	$result2 = $db2->fetchAll();
	$nhomth = new NhomThucHanh();
	
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="Libraries/css/style.css" rel="stylesheet" type="text/css" />
<title>Untitled Document</title>
</head>

<body>
<form name="khoiluonggd" method="POST">
<table align="center" class="font" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="main_1"><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align="center" class="main_1">Khối Lượng Giảng Dạy- Học kì:
      <?php echo $hocki?>-Năm học:<?php echo $namhoc?></td>
    <td class="main_1"><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  
  <tr>
  <td class="border_1" colspan="3" valign="top">
	<table width="100%" align="center" cellpadding="0" cellspacing="0">
		 <tr>
			<td colspan="13" align="center" class="main_3" >Cán Bộ: <?php echo $hoten?> - MSCB: <?php echo $maso?></td>
		</tr>
	  <tr>
		<td width="4%" rowspan="2" align="center" valign="middle" class="main_3"><strong>STT</strong></td>
		<td width="24%" rowspan="2" align="center" valign="middle" class="main_3" ><strong>Nội dungMã HP </strong></td>
		<td width="6%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Ký hiệu </strong></td>
	
		<td width="5%" rowspan="2" align="center" valign="middle" class="main_3"><strong>DVHT</strong></td>
		<td width="5%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Lớp</strong></td>
		<td width="5%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Số SV </strong></td>
		<td width="6%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Số nhóm </strong></td>
		<td width="5%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Giờ thực tế </strong></td>
		<td width="5%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Hệ số quy dổi </strong></td>
	
		<td colspan="3" align="center" valign="middle" class="main_3"><strong>Giờ chuẩn theo học kỳ</strong></td>
		<td width="10%" rowspan="2" align="center" valign="middle" class="main_3"><strong>Tổng số giờ dạy CQ </strong></td>
	  </tr>
	  <tr>
		<td width="6%" align="center" valign="middle" class="main_3"><strong>HKII</strong></td>
		<td width="4%" align="center" valign="middle" class="main_3"><strong>HK hè </strong></td>
		<td width="4%" align="center" valign="middle" class="main_3"><strong>HKI</strong></td>
	  </tr>
	  <tr>
		<td align="center" valign="middle" class="main_3">1</td>
		<td colspan="12" align="left" valign="middle" class='level_1_2'><strong>Giảng dạy lý thuyết CĐ,ĐH CQ </strong></td>
	  </tr>
	  <?php
		$i = 0;
		$tonglthk1 = 0;
		$tonglthk2 = 0;
		$tonglthk3 = 0;
	  while ($rows = mysql_fetch_array($result))
	  {	
		
		$lophp->setMaLopHP($rows['malophp']);
		$tonglthk1 = $tonglthk1 + $lophp->tongSoTietDaDay();
		$tonglthk2 = $tonglthk2 + $lophp->tongSoTietDaDay();
		$tonglthk3 = $tonglthk3 + $lophp->tongSoTietDaDay();
		//$nhatki->setMaLopHP($rows['malophp']);
		if ($rows['manhom']==1 || $rows['manhom']==3 )
		{
			$i++;
			$c = 2- $i%2;
	  ?>
		  <tr>
			<td align="right" valign="middle" class="main_3">1.<?php echo $i?>&nbsp;</td>
			<td align="left" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;&nbsp;<?php echo $rows['tenhp']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['kihieu']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotc']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['malophp']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['siso']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
		
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==2) echo round($lophp->tongSoTietDaDay(),0);?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==3) echo $lophp->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==1) echo $lophp->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
		  </tr>
		<?php
			}
		}
		?>
	  <tr>
		<td align="center" valign="middle" class="main_3">&nbsp;</td>
		<td colspan="8" align="left" valign="middle" class="level_1_1"><strong>Cộng</strong></td>
	
		<td align="center" valign="middle"  class="level_1_1"><b>
		  <?php if ($hocki==2) echo $tonglthk2;?>
		</b></td>
		<td align="center" valign="middle"  class="level_1_1"><b>
		  <?php if ($hocki==3) echo $tonglthk3;?>
		</b></td>
		<td align="center" valign="middle" class="level_1_1" ><b>
		  <?php if ($hocki==1) echo $tonglthk1;?>
		</b></td>
		<td align="center" valign="middle"  class="level_1_1">&nbsp;</td>
	  </tr>
	  <tr>
		<td align="center" valign="middle" class="main_3">2</td>
		<td colspan="12" align="left" valign="middle" class='level_1_2'><strong>Dạy thực hành, thí nghiệm </strong></td>
	  </tr>
	   <?php
			$i = 0;
			$tongthhk1 = 0;
			$tongthhk2 = 0;
			$tongthhk3 = 0;
		  while ($rows = mysql_fetch_array($result2))
		  {
			
			$nhomth->setMaNhomTH($rows['manhomth']);
			$tongthhk1 = $tongthhk1 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
			$tongthhk2 = $tongthhk2 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
			$tongthhk3 = $tongthhk3 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
			if ($rows['manhom']==2 || $rows['manhom']==3 )
			{
				$i++;
				$c = 2- $i%2;
		  ?>
	  <tr>
			<td align="right" valign="middle" class="main_3">2.<?php echo $i?>&nbsp;</td>
			<td align="left" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;&nbsp;<?php echo $rows['tenhp']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['kihieu']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotc']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['manhomth']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['siso']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
		
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $nhomth->getHeSo()*$nhomth->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==2) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==3) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php if ($hocki==1) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'>&nbsp;</td>
	  </tr>
		<?php
			}
		}
		?>
	  <tr>
		<td align="center" valign="middle" class="main_3">&nbsp;</td>
		<td colspan="8" align="left" valign="middle" class='level_1_1'><strong>Cộng</strong></td>
		<td align="center" valign="middle" class='level_1_1'><b><?php if ($hocki==2) echo round($tongthhk2);?></b></td>
		<td align="center" valign="middle" class='level_1_1'><b><?php if ($hocki==3) echo round($tongthhk3);?></b></td>
		<td align="center" valign="middle" class='level_1_1'><b><?php if ($hocki==1) echo round($tongthhk1);?></b></td>
		<td align="center" valign="middle" class='level_1_1'><?php  echo round($tongthhk1+$tonghk2+tonghk3);?></td>
	  </tr>
	  
	  
	  
	  <tr>
		<td colspan="13" align="center" valign="middle"><input type="button" name="btndownload" value="Download" onclick="printTL('<?php echo $namhoc?>','<?php echo $hocki?>','<?php echo $maso?>')" class="button_1"/></td>
		</tr>
	</table>
	</td>
	</tr>
</table>
</form>
</body>
</html>
